package com.toy.utils;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.toy.query.BaseQuery;

import java.util.List;

public class PageUtil {
    private static PageInfo pageInfo;
    public static void initPageHelper(BaseQuery baseQuery) {
        PageHelper.startPage(baseQuery.getPageNum(),baseQuery.getPageSize());
    }

    public static  <T>PageInfo initPageInfo(List<T> list){
        if (list.size()>0 && null != list) {
            pageInfo = new PageInfo<>(list);
        }
        return pageInfo;
    }

    public static <T>Long getPageInfoTotal(List<T> list) {
        initPageInfo(list);
        return  pageInfo.getTotal();
    }

}
